package com.mls.fivedistrict.server.impl;

import com.mls.fivedistrict.common.ServiceResponse;
import com.mls.fivedistrict.dao.InvitationMapper;
import com.mls.fivedistrict.dao.UserMapper;
import com.mls.fivedistrict.pojo.Invitation;
import com.mls.fivedistrict.pojo.InvitationExample;
import com.mls.fivedistrict.server.UserInvitationService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * Created by chenxiuxiang on 2018/3/22.
 */
@Service("userInvitationService")
public class UserInvitationServiceImpl implements UserInvitationService {
    @Resource(name = "invitationMapper")
    InvitationMapper invitationMapper;
    @Override
    public ServiceResponse addUserInvitation(Long userId, Long invitationUserId) {
        Invitation invitation = new Invitation();
        invitation.setInviteeUserId(userId);
        invitation.setInviterUserId(invitationUserId);
        int row = invitationMapper.insert(invitation);
        if (row > 0) {
            return ServiceResponse.createSuccessResponse();
        }
        return ServiceResponse.createErrorResponse("邀请关系设置失败");
    }
}
